﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Windows.Controls;

namespace SQLDiag.UI.WPF
{
    public class Engine
    {
        public static void LoadPerfmon(XDocument doc)
        {
            TreeView tvPerfmonCounters = new TreeView();
            //add root node
            TreeViewItem tnRoot = new TreeViewItem();
            tnRoot.Header = "Perfmon Objects";

            tvPerfmonCounters.Items.Add(tnRoot);

            ////load perfmon objects
            //var perfObjects = from po in doc.Descendants("PerfmonObject")
            //                  select po;

            //foreach (var item in perfObjects)
            //{
            //    TreeNode tn = new TreeNode(item.Attributes("name").First().Value);

            //    //initialize the checked values -- Added by Shen 12/12/2010
            //    if (item.Attributes("enabled").Count() != 0)
            //        if (item.Attributes("enabled").First().Value == "true")
            //        {
            //            tn.BackColor = System.Drawing.SystemColors.ControlDark;
            //            tn.Checked = true;
            //        }

            //    tnRoot.Nodes.Add(tn);

            //    //load perfmon counters under the object
            //    var perfmonCounters = from pc in item.Descendants("PerfmonCounter")
            //                          select pc;

            //    foreach (var itemPc in perfmonCounters)
            //    {
            //        TreeNode tnPc = new TreeNode(itemPc.Attributes("name").First().Value);

            //        //initialize the checked values -- Added by Shen 12/12/2010
            //        if (itemPc.Attributes("enabled").Count() != 0)
            //            if (itemPc.Attributes("enabled").First().Value == "true")
            //            {
            //                if (!tn.Checked)
            //                    tn.BackColor = System.Drawing.SystemColors.ControlDark;
            //                tnPc.Checked = true;
            //            }

            //        tn.Nodes.Add(tnPc);
            //    }
            //}

            //tnRoot.Expand();

            //return tvPerfmonCounters;
        }

        public static void LoadProfiler(XDocument doc)
        {
            
            
        }
    }
}
